﻿using System.Collections.Specialized;
using System.Web.Mvc;
using Xoohoo.Extensions;
using Xoohoo.Modules.Admin.Models;

namespace Xoohoo.Modules.Admin.ModelBinders
{
    public class UserSignInInputModelBinder : IModelBinder
    {
        public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
        {
            var valueProvider = bindingContext.ValueProvider;
            NameValueCollection form = controllerContext.HttpContext.Request.Form;
            string username = valueProvider.GetAttemptedValue("username");
            string password = valueProvider.GetAttemptedValue("password");
            string validateCode = valueProvider.GetAttemptedValue("validateCode");

            return new UserSignInInput(username, password, validateCode);
        }
    }
}
